package com.ipc.admin.controller.gwl;

import com.ipc.admin.service.gwl.service.ThirdScreenService;
import com.ipc.common.pojo.bo.gwl.PageAndSearchBo;
import com.ipc.common.pojo.vo.R;
import com.ipc.core.entity.gwl.ThirdScreen;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/api/thirdScreen/")
@Api(tags = "三级诱导屏")
public class ThirdScreenController {

    @Resource
    private ThirdScreenService service;

    @ApiOperation(value = "新增诱导屏",notes = "新增诱导屏，要求所有信息不能为空")
    @PostMapping("add")
    public R add(@RequestBody @Valid ThirdScreen screen, BindingResult result){
        return service.add(screen, result);
    }

    @ApiOperation(value = "根据ID删除员工")
    @PostMapping("deleteById")
    public R del(@RequestBody Map<String, Integer> map) {
        return service.del(map.get("id"));
    }

    @ApiOperation(value = "根据ID数组批量删除", notes = "list是一个装有ID的数组")
    @PostMapping("delBatch")
    public R delBatch(@RequestBody List<Integer> list) {
        return service.delBatch(list);
    }

    @ApiOperation(value = "修改信息", notes = "需要ID，文档显示有误！")
    @PostMapping("update")
    public R update(@RequestBody ThirdScreen screen) {
        return service.update(screen);
    }

    @ApiOperation(value = "根据ID查询诱导屏详情")
    @GetMapping("selectOne")
    public R selectOne(@ApiParam(required = true) int id){
        return service.selectOne(id);
    }

    @ApiOperation(value = "查询所有")
    @GetMapping("selectAll")
    public R page(PageAndSearchBo bo){
        return service.page(bo);
    }

    @ApiOperation(value = "全局修改显示内容")
    @GetMapping("allDisplay")
    public R allDisplay(String display) {
        return service.allDisplay(display);
    }
    @ApiOperation(value = "导出数据到Excel")
    @GetMapping("export")
    public R export(HttpServletResponse response){
        return service.export(response);
    }

    @ApiOperation(value = "从Excel导入数据")
    @GetMapping("import")
    public R importData(MultipartFile file){
        return service.importData(file);
    }
}